<template>
  <div class="ecuUpdateDetailComp h100">
    <component :is="compName" :query="query" :ecu-lists="ecuLists" :loading-base-info="loadingBaseInfoData"></component>
  </div>
</template>
<script>
import RichShow from './richShow.vue'
import TableShow from './tableShow.vue'
import taskApi from '@/api/modules/task'
export default {
  components: {
    RichShow,
    TableShow
  },
  computed: {
    // 查询条件
    query: {
      type: Object,
      default () {
        return null
      }
    }
  },
  data () {
    return {
      compName: 'RichShow',
      loadingBaseInfoData: false,
      ecuLists: []
    }
  },
  watch: {
    query: {
      handler (val) {
        if (!val) {
          this.ecuLists = []
          return
        }
        this.getEcuBaseInfoData()
      },
      immediate: true
    }
  },
  methods: {
    // 获取当前任务下的所有零件信息,不包括N次升级信息
    getEcuBaseInfoData () {
      this.loadingBaseInfoData = true
      this.ecuLists = []
      taskApi.getTaskVehicleEcuList(this.query).then(res => {
        this.ecuLists = res.data
      }).finally(() => {
        this.loadingBaseInfoData = false
      })
    }
  }
}
</script>
<style lang="less" scoped>
.ecuUpdateDetailComp {
    background-color: orange;
}
</style>
